#ifndef __MUTEX_H__
#define __MUTEX_H__

#ifdef _WIN32
#include <windows.h>

class Mutex
{
public:
	Mutex() {InitializeCriticalSection(&m_cs);}
	~Mutex() {DeleteCriticalSection(&m_cs);}
public:
	void Lock() {EnterCriticalSection(&m_cs);}
	void Unlock() {LeaveCriticalSection(&m_cs);}
private:
	CRITICAL_SECTION m_cs;
};

#else 

#include <pthread.h>
class Mutex
{
public:
	Mutex() {pthread_mutex_init(&m_mutex,NULL);}
	~Mutex() {pthread_mutex_destroy(&m_mutex);}
public:
	void Lock() {pthread_mutex_lock(&m_mutex);}
	void Unlock() {pthread_mutex_unlock(&m_mutex);}
private:
	pthread_mutex_t m_mutex;
};

#endif

#endif

